package com.bilgeadam.hibernate.program;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 16, 2014 3:54:34 PM
 * @version 1.0.0
 */
@Entity
@Table(name = "VEHICLES")
@Inheritance(strategy = InheritanceType.JOINED)
public class Vehicle implements Serializable {

	private int id;
	private String name;

	@Id
	@GeneratedValue
	@Column(name = "VEHICLE_ID")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "VEHICLE_NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		Vehicle other = (Vehicle) obj;
		if (id != other.id) return false;
		return true;
	}

	@Override
	public String toString() {
		return "Vehicle [id=" + id + ", name=" + name + "]";
	}

}
